package com.ambientrs.script;

import com.ambientrs.script.methods.Methods;

import javax.swing.*;
import java.awt.*;

@Manifest(name = "", authors = {""})
public abstract class Script extends Methods implements Runnable {

    private long startTime;

    public Script() {
        startTime = System.currentTimeMillis();
    }

    /**
     * Executes when the script is started.
     *
     * @return True if the script should start.
     */
    public boolean onStart() {
        return true;
    }

    /**
     * Executes when the script is stopped.
     */
    public void onStop() {

    }

    /**
     * Paints graphics onto the screen.
     */
    public void paint(Graphics g) {

    }

    /**
     * Returns the amount of time the script has been running, in millis.
     *
     * @return The time the script has been running.
     */
    public long getTimeRunning() {
        return System.currentTimeMillis() - startTime;
    }

    /**
     * Overriding this method will cause the JPanel to be added to the Script
     * Selector when the script is started.
     *
     * @return A JPanel with the script's GUI settings.
     */
    public JPanel getGUI() {
        return null;
    }

}
